package com.sdgakj.dto.base;

import java.io.Serializable;

import org.apache.commons.lang3.builder.ToStringBuilder;

public class ResResult implements Serializable {
    
    private static final long serialVersionUID = 1451237172552183597L;
    
    public int resCode;
    public String resMsg;
    public Object data;
    public Object backup;
    
    public static final int INTERFACE_MODEL = 1;
    public static final int WEB_MODEL = 2;
    
    public ResResult() {
        super();
        this.resCode = ResCode.SUCCESS.resCode;
        this.resMsg = ResCode.SUCCESS.resMsg;
    }
    
    public ResResult(ResCode code) {
        super();
        this.resCode = code.resCode;
        this.resMsg = code.resMsg;
    }
    
    public ResResult(int model) {
        super();
        switch (model) {
        case INTERFACE_MODEL:
            this.resCode = ResCode.SUCCESS.resCode;
            this.resMsg = ResCode.SUCCESS.resMsg;
            break;
        case WEB_MODEL:
            this.resCode = ResCode.MGR_SUCCESS.resCode;
            this.resMsg = ResCode.MGR_SUCCESS.resMsg;
            break;
        }
    }
    
    public ResResult(String resMsg) {
        super();
        this.resCode = ResCode.SUCCESS.resCode;
        this.resMsg = resMsg;
    }
    
    public int getResCode() {
        return resCode;
    }

    public void setResCode(int resCode) {
        this.resCode = resCode;
    }

    public String getResMsg() {
        return resMsg;
    }

    public void setResMsg(String resMsg) {
        this.resMsg = resMsg;
    }

    public Object getData() {
        return data;
    }
    public void setData(Object data) {
        this.data = data;
    }
    
    public void setResCode(ResCode resCode) {
        this.resCode = resCode.resCode;
        this.resMsg = resCode.resMsg;
    }
    
    public Object getBackup() {
		return backup;
	}

	public void setBackup(Object backup) {
		this.backup = backup;
	}

	@Override
    public String toString() {
        return ToStringBuilder.reflectionToString(this);
    }
}
